package com.mk.admin.service.impl;

import com.mk.admin.mapper.EmrMapper;
import com.mk.admin.model.ResultDto;
import com.mk.admin.model.entity.EmrEntity;
import com.mk.admin.model.vo.EmrVo;
import com.mk.admin.service.EmrService;
import com.mk.admin.util.JSONCopy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class EmrServiceImpl implements EmrService {

    @Autowired
    private EmrMapper emrMapper;

    @Override
    public ResultDto getEmrInfoByDocID(EmrVo vo) {
        EmrEntity entity = JSONCopy.copy(vo, EmrEntity.class);
        return ResultDto.data(emrMapper.count(entity), emrMapper.select(entity));
    }
    @Override
    public ResultDto update(EmrVo vo) {
        EmrEntity entity = JSONCopy.copy(vo, EmrEntity.class);
        return ResultDto.data(emrMapper.updateById(entity));
    }

    @Override
    public ResultDto add(EmrVo vo) {
        return ResultDto.data(emrMapper.insert(JSONCopy.copy(vo, EmrEntity.class)));
    }
}
